package com.nl.lib_core.view

import android.content.Context
import android.util.AttributeSet
import android.widget.ImageView
import android.widget.RelativeLayout
import androidx.annotation.ColorRes
import androidx.annotation.DrawableRes
import com.nl.lib_core.R

/** 作者: wangfei 创建时间: 2021/9/1 包名: com.nl.lib_core.view 类名: NoDataView */
class NoDataView(context: Context, attrs: AttributeSet) : RelativeLayout(context, attrs) {

  private val mRlNoDataRoot: RelativeLayout
  private val mImgNoDataView: ImageView

  init {
    inflate(context, R.layout.core_view_no_data, this)
    mRlNoDataRoot = findViewById(R.id.rl_no_data_root)
    mImgNoDataView = findViewById(R.id.img_no_data)
  }

  /** 设置没有数据的view的背景色 */
  fun setNoDataBackground(@ColorRes colorResId: Int) {
    mRlNoDataRoot.setBackgroundColor(resources.getColor(colorResId))
  }

  /** 设置没有数据展示的view图片 */
  fun setNoDataView(@DrawableRes imgResId: Int) {
    mImgNoDataView.setImageResource(imgResId)
  }
}
